package com.qf.main.login.controller;

import com.qf.common.base.result.ResponseResult;
import com.qf.main.login.common.qo.SysRoleQo;
import com.qf.main.login.common.vo.SysRoleVo;
import com.qf.main.login.service.RoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author chengqiang
 * @Create 2024-01-19-16:21
 * @Description:
 */
@RestController
@RequestMapping("/role")
@Api(tags = "角色")
@CrossOrigin
public class RoleController {

    @Resource
    public RoleService roleService;


    @PostMapping("/add")
    @ResponseBody
    @ApiOperation("添加角色")
    @ApiResponses({@ApiResponse(code = 200, message = "成功", response = String.class), @ApiResponse(code = 400, message = "系统错误")})
    public ResponseResult<Integer> add(@RequestBody SysRoleQo sysRoleQo){
        Integer integer = roleService.insertRole(sysRoleQo);
        return ResponseResult.success(integer);
    }

    @GetMapping("/list")
    @ResponseBody
    @ApiOperation("查询全部角色")
    @ApiResponses({@ApiResponse(code = 200, message = "成功", response = String.class), @ApiResponse(code = 400, message = "系统错误")})
    public ResponseResult<List<SysRoleVo>> listSysRole(){
        return ResponseResult.success(roleService.queryRoles());
    }


}
